package cn.iocoder.yudao.module.book.dal.mysql.images;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.book.controller.app.readBook.vo.AppbookImagesRespVO;
import cn.iocoder.yudao.module.book.dal.dataobject.images.bookImagesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.book.controller.admin.images.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 绘本页 Mapper
 *
 * @author xi
 */
@Mapper
public interface bookImagesMapper extends BaseMapperX<bookImagesDO> {

    default PageResult<bookImagesDO> selectPage(bookImagesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<bookImagesDO>()
                .eqIfPresent(bookImagesDO::getImageId, reqVO.getImageId())
                .eqIfPresent(bookImagesDO::getBookId, reqVO.getBookId())
                .eqIfPresent(bookImagesDO::getImageUrl, reqVO.getImageUrl())
                .eqIfPresent(bookImagesDO::getImageOrder, reqVO.getImageOrder())
                .eqIfPresent(bookImagesDO::getAudioUrl, reqVO.getAudioUrl())
                .betweenIfPresent(bookImagesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(bookImagesDO::getImageId));
    }

    List<AppbookImagesRespVO> getBookImagesByBookId(@Param("bookId") Integer bookId);

    /**
     * 获取某绘本(bookId)下图片的最大顺序
     */
    Integer selectMaxOrderByBookId(@Param("bookId") Integer bookId);
}